<?php

use think\migration\Migrator;
use think\migration\db\Column;

class AirQualityWeatherForecastHour extends Migrator
{
    public function up()
    {
        $table = $this->table('air_quality_weather_forecast_hour');
        $table
            //step1:城市ID
            ->addColumn('region_id', 'integer', ['comment'=>'区域ID',])

            //step2:时间
            ->addColumn('predict_time', 'datetime', ['comment' => '预报时间'])
            ->addColumn('publish_time', 'datetime', ['comment' => '发布时间'])
            ->addColumn('create_time', 'datetime', [ 'comment' => '入库时间'])

            //step3:天气六参
            //参数1
            ->addColumn('surface_temp', 'integer', ['limit' => 4, 'comment' => '气温'])
            //参数2
            ->addColumn('surface_wind', 'integer', ['limit' => 4, 'comment' => '风力'])
            //参数3
            ->addColumn('wind_dir', 'string', ['limit' => 50, 'comment' => '风向'])
            //参数4
            ->addColumn('rh', 'integer', ['limit' => 10, 'comment' => '相对湿度（录入为数字例42，输出结果为百分比如42%)'])
            //参数5：总云量对应的的天气
            ->addColumn('cloud_cover', 'integer', ['limit' => 10, 'comment' => '总云量'])
            ->addColumn('sky_condition', 'string', ['limit' => 50, 'comment' => '总云量对应的天空情况'])
            ->addColumn('sky_condition_icon', 'string', ['limit' => 50, 'comment' => '总云量对应的天空情况对应的图标'])
            //参数6
            ->addColumn('pressure', 'integer', ['limit' => 10, 'comment' => '气压'])

            //注释
            ->setComment('空气质量 - 天气 - 预报（小时）')

            //引擎
            ->setEngine('InnoDB')
            ->save();
    }

    public function down()
    {
        $this->table('air_quality_weather_forecast_hour')->drop();
    }
}
